<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="姓名" prop="ecaName">
        <el-input
          v-model="queryParams.ecaName"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="ecaPhone">
        <el-input
          v-model="queryParams.ecaPhone"
          placeholder="请输入手机号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属网格" prop="ehGridId">
        <el-input
          v-model="queryParams.ehGridId"
          placeholder="请输入所属网格"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="ecaStatus">
        <el-input
          v-model="queryParams.ecaStatus"
          placeholder="请输入状态"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="ehSignUpActivitiesList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column prop="ecaId" header-align="center" align="center" label="编号"></el-table-column>
      <el-table-column prop="ecaActivitiesId" header-align="center" align="center" label="活动编号"></el-table-column>
      <el-table-column prop="ehGridName" header-align="center" align="center" label="所属网格"></el-table-column>
      <el-table-column prop="ecaName" header-align="center" align="center" label="姓名"></el-table-column>
      <el-table-column prop="ecaPhone" header-align="center" align="center" label="手机号"></el-table-column>
      <el-table-column prop="ecaAge" header-align="center" align="center" label="年龄"></el-table-column>
      <el-table-column prop="ecaSex" header-align="center" align="center" label="性别">
        <template scope="scope">
          <p v-if="scope.row.ecaSex==0">男</p>
          <p v-if="scope.row.ecaSex==1">女</p>
        </template>
      </el-table-column>
      <el-table-column prop="ecaSignUpTime" header-align="center" align="center" label="报名时间"></el-table-column>
      <!-- <el-table-column prop="ecaIsSignUp" header-align="center" align="center" label="是否打卡"></el-table-column>
      <el-table-column
        prop="ecaIsEvidenceUpload"
        header-align="center"
        align="center"
        label="是否上传证据"
      ></el-table-column>-->
      <el-table-column prop="ecaStatus" header-align="center" align="center" label="状态"></el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-info" @click="handleInfo(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules">
        <el-row>
          <el-col :span="8">
            <el-form-item label="姓名：" prop="ecaName">{{form.ecaName}}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="手机号：" prop="ecaPhone">{{form.ecaPhone}}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="年龄：" prop="ecaAge">{{form.ecaAge}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item
              label="活动编号："
              prop="ecaActivitiesId"
            >{{form.ecaActivitiesId}}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所属网格：" prop="ehGridName">{{form.ehGridName}}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="状态：" prop="ecaStatus">{{form.ecaStatus}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item
              label="报名时间："
              prop="ecaSignUpTime"
            >{{form.ecaSignUpTime}}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="打卡时间："
              prop="ecaPunchTime"
            >{{form.ecaPunchTime}}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="证据上传时间："
              prop="ecaUploadTime"
            >{{form.ecaUploadTime}}</el-form-item>
          </el-col>
        </el-row>        
        <el-row>          
          <el-col :span="8">
            <el-form-item label="性别：" prop="ecaSex">
              <div v-if="form.ecaSex==0">男</div>
              <div v-if="form.ecaSex==1">女</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否打卡：" prop="ecaIsSignUp">
              <div v-if="form.ecaIsSignUp==true">是</div>
              <div v-if="form.ecaIsSignUp==false">否</div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否上传证据：" prop="ecaIsEvidenceUpload">
              <div v-if="form.ecaIsEvidenceUpload==true">是</div>
              <div v-if="form.ecaIsEvidenceUpload==false">否</div>
            </el-form-item>
          </el-col>
        </el-row>        
        <el-row>
          <el-col :span="24">
            <el-form-item label="打卡地点：" prop="ecaPosition">{{form.ecaPosition}}</el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="审核结果说明：" prop="ecaResult">{{form.ecaResult}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="证据图片：" prop="ecaImgJson">
              <div v-for="imgString in this.ehSignUpPicList" :key="imgString">
                <el-col :span="6">
                  <img :src="imgString" width="120" height="120" />
                </el-col>
              </div>
            </el-form-item>
          </el-col>
        </el-row>        
        <el-row>
          <el-col :span="24">
            <el-form-item label="打卡图片：" prop="ecaPunchImgJson">
              <img :src="ecaunchImg" width="120" height="120" />
            </el-form-item>            
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleInfo">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  listEhSignUpActivities,
  getEhSignUpActivities,
  delEhSignUpActivities,
  addEhSignUpActivities,
  updateEhSignUpActivities
} from "@/api/volunteer/ehsignupactivities";
export default {
  name: "EhSignUpActivities",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      ehSignUpActivitiesList: [],
      //图片列表
      ehSignUpPicList: [],
      //打卡图片列表
      ecaunchImg: "",
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 状态数据字典
      statusOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ehGridId: undefined,
        ecaActivitiesId: undefined,
        ecaSignUpTime: undefined,
        ecaPunchTime: undefined,
        ecaPosition: undefined,
        ecaIsSignUp: undefined,
        ecaIsEvidenceUpload: undefined,
        ecaStatus: undefined,
        ecaResult: undefined,
        ecaUploadTime: undefined,
        ecaName: undefined,
        ecaPhone: undefined,
        ecaAge: undefined,
        ecaSex: undefined
      },
      // 表单参数
      form: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询活动报名表列表 */
    getList() {
      this.loading = true;
      listEhSignUpActivities(this.queryParams).then(response => {
        this.ehSignUpActivitiesList = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 查看按钮操作 */
    handleInfo(row) {
      const ecaId = row.ecaId || this.ids;
      getEhSignUpActivities(ecaId).then(response => {
        this.form = response.data;
        const jsonStringArray = JSON.parse(this.form.ecaImgJson);
        const jsonString = JSON.parse(this.form.ecaPunchImgJson);
        this.ecaunchImg = jsonString.imgArr;
        console.log("取到的图片：" + this.ecaunchImg);
        this.ehSignUpPicList = jsonStringArray.imgArr;
        console.log("取到的图片数组：" + this.ehSignUpPicList);
        // handlePicArray(jsonString);
        this.open = true;
        this.title = "查看活动报名信息";
      });
    }
  }
};
</script>
